<template>
  <div class="layout">
    <div class="banner_box">
      <NewBanner :image="require('@/assets/image/service/banner.png')" style="height:500px"></NewBanner>
      <div class="settled_box">
        <div class="settled_btn" @click="settled" v-if="resultCompany ==0">
          立即入驻
        </div>
        <div class="settled_btn wid" @click="progress" v-if="resultCompany ==1">
          查看入驻进度
        </div>
        <div class="settled_btn1 wid" v-if="resultCompany ==2">
          已入驻
        </div>
      </div>
    </div>
    <EnterpriseEntry></EnterpriseEntry>
    <el-dialog
      title="入驻进度"
      :visible.sync="visible"
      width="941px"
      :before-close="handleClose"
      class="closeDialog borderdialog"
    >
      <div class="evaluateform">
        <div class="speed" v-for="(item, index) in speedList" :key="index">
          <template v-if="item.status ==1">
            <div class="img">
              	<img src="@/assets/image/service/speed.png" />
                <div class="img_zi">{{index+1}}</div>
            </div>
             <div class="title">{{item.nodeName}}</div>
          </template>
          <template v-if="item.status ==2">
            <div class="img">
              	<img src="@/assets/image/service/speed2.png" />
                <div class="img_ico">
                  <img src="@/assets/image/service/speed4.png" />
                </div>
            </div>
             <div class="title">{{item.nodeName}}</div>
             <div class="time">{{item.gmtCreateStr}}</div>
          </template>
          <template v-if="item.status ==3">
            <div class="img">
              	<img src="@/assets/image/service/speed3.png" />
            </div>
             <div class="title" :class="{'red' : item.status ==3}">{{item.nodeName}}</div>
             <div class="time">{{item.gmtCreateStr}}</div>
          </template>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import EnterpriseEntry from "./components/enterpriseEntry"

import { isLogin } from "@/utils/util.js";
import { getquerySettledProcess, getcheckHasSettled, getprofile } from "@/common/api/service.js";
export default {
  name: "service",
  components: {
    EnterpriseEntry 
  },
  data() {
    return {
      companyInfo: {},
      bigImage: "",
      showImgDiv: false,
      visible: false, // 流程进度弹窗显示
      login: false,
      current: 1,
      pageSize: 10,
      token: '',
      companyId: '',
      companyName: '',
      speedList: [],
      resultCompany: '',
    };
  },
  methods: {
    
    // 查询服务机构入驻流程
    async getquerySettledProcess(corporationId){
      let obj = {
        corporationId
      }
      let res = await getquerySettledProcess(obj)
      // let api = `${hostqt}/commerce/agency/querySettledProcess`
      // let res = await request(this, api, obj, "POST",{},false,'commerce/agency/querySettledProcess');
      if(res.status == 200) {
        this.speedList = res.result.nodeList
      }
      console.log('querySettledProcess', res)
    },
     // 判断服务机构是否入驻
    async getcheckHasSettled(corporationId){
      let obj = {
        corporationId
      }
      let res = await getcheckHasSettled(obj)
      // let api = `${hostqt}/commerce/agency/checkHasSettled`
      // let res = await request(this, api, obj, "POST",{},false,'commerce/agency/checkHasSettled');
      console.log('checkHasSettled', res)
      this.$nextTick(()=>{
      if(res.status == 200) {
        this.resultCompany = res.result.result
        if(res.result.result == 1) {
          this.getquerySettledProcess(corporationId)
        }
      }
      })
    },
    // 获取企业基本信息
    async getprofile(){
      let res = await getprofile(obj)
      // let api = `${host}/company/profile`
      // let res = await request(this, api, {}, "GET");
      console.log('res', res)
      if(res.code == 200) {
        this.companyName = res.data.companyName
        this.companyId = res.data.companyId
        this.getcheckHasSettled(res.data.companyId)
      }
    },
    // 跳转入驻页
    settled(){
      this.$CheckRole('服务机构认证', () => {
        this.$router.push(
          { 
            path: 'serviceEnter',
            query: {
              companyId: this.companyId,
              companyName: this.companyName
            }
          }
        )
      })
    },
    // 打开入驻流程弹窗
    progress(){
      this.visible = true
    },
    // 关闭入驻流程弹窗
    handleClose(){
      this.visible = false
    }
  },
  mounted() {
    // 检测是否登录,如果登录才查询用户信息接口
    if(isLogin()){
      // this.$message.error('请先登录！！')
      this.getprofile()
    }
  },
  created() {
    // this.getLogin()
    // this.getprofile()
  }
};
</script>

<style scoped>
::v-deep.layout .el-dialog__header{
  text-align: left;
}
.breadcrumb {
  width: 1000px;
  margin: 20px 0;
}

.layout {
  min-height: 100vh;
  position: relative;
  padding-bottom: 150px;
  box-sizing: border-box;
}
.banner_box{
  height: 551px;
}
.banner_box .settled_box{
  width: 519px;
  height: 185px;
  background: red;
  position: relative;
  top: -134px;
  z-index: 99;
  margin: 0 auto;
  background: url("~@/assets/image/service/movebg.png") no-repeat center top;
}
.banner_box .settled_box .settled_btn{
  width: 96px;
  height: 34px;
  background: rgba(255,255,255,0.25);
  border: 1px solid #FFFFFF;
  border-radius: 20px;
  position: absolute;
  bottom: 26px;
  left: 211px;
  color: #fff;
  line-height: 34px;
  cursor: pointer;
}
.banner_box .settled_box .settled_btn1{
  width: 96px;
  height: 34px;
  position: absolute;
  bottom: 26px;
  left: 211px;
  color: #F09450;
  line-height: 34px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.50);
  font-size: 16px;
}
.banner_box .settled_box .wid{
  width: 120px;
  left: 200px;
}
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}
.evaluateform{
  width: 800px;
  height: 160px;
  margin: 0 auto;
  display: flex;
  padding-top: 30px;
}
.evaluateform .speed{
  width: 198px;
  margin-left: 1px;
}
.evaluateform .speed .img{
  position: relative;
}
.evaluateform .speed .img .img_zi{
  position: absolute;
  top: 9px;
  left: 93px;
  font-size: 20px;
  color: #fff;
  font-weight: bold;
}
.evaluateform .speed .img .img_ico{
  position: absolute;
  top: 15px;
  left: 89px;
}
.evaluateform .speed  .title{
  font-size: 18px;
  color: #333333;
  text-align: center;
  font-weight: 500;
  margin-top: 8px;
}
.evaluateform .speed .time{
  font-size: 12px;
  color: #666666;
  text-align: center;
  margin-top: 8px;
}
.evaluateform .speed .red{
  color: #DB3F24
}
</style>
